package heathot.servlet;

import heathot.bookservice.BookService;
import heathot.bookservice.BookServiceimpl;
import heathot.entiy.Car;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sound.midi.Soundbank;

public class UpateServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String value = request.getParameter("value");
		String id = request.getParameter("id");
		System.out.println("value="+value);
		System.out.println("id="+id);
		BookService service = new BookServiceimpl();
		int count = 0;
		if(value != null && !"".equals(value)){
			count = Integer.parseInt(value);
		}
		int bookId = 0;
		if(id != null && !"".equals(id)){
			bookId = Integer.parseInt(id);
		}
		Car car  = (Car) request.getSession().getAttribute("car");
		String result = service.updateCarItem(bookId, count, car);
		out.println(result);
		out.flush();
		out.close();
		}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			doGet(request, response);
		
	}

}
